import React, { PureComponent } from 'react';
import { connect } from 'dva';
import { Form } from '@ant-design/compatible';
import '@ant-design/compatible/assets/index.css';
import { Card, Table } from 'antd';
import moment from 'moment';

@connect(({ integratedquery, loading }) => ({
  loading: loading.models.integratedquery,
  crmquoDataList: integratedquery.crmquoDataList, // 报价单列表数据
}))
@Form.create()
class EmpInfor extends PureComponent {
  constructor(props) {
    super(props);
    this.state = {};
  }

  componentDidMount() {}

  jumpRouting = (targetRouter, quoId) => {
    const { jumpRouting } = this.props;
    jumpRouting(targetRouter, quoId);
  };

  render() {
    const { crmquoDataList, loading } = this.props;
    const columns = [
      {
        title: '报价单编号',
        dataIndex: 'quoNo',
        onHeaderCell: () => ({
          style: {
            fontWeight: 'bold',
            textAlign: 'left',
          },
        }),
        onCell: () => ({ style: { textAlign: 'left' } }),
      },
      {
        title: '报价单名称',
        dataIndex: 'quoName',
        onCell: () => ({ style: { textAlign: 'left' } }),
        onHeaderCell: () => ({ style: { textAlign: 'left' } }),
      },
      {
        title: '合同名称',
        dataIndex: 'contName',
        onCell: () => ({ style: { textAlign: 'left' } }),
        onHeaderCell: () => ({ style: { textAlign: 'left' } }),
      },
      {
        title: '状态',
        dataIndex: 'quoStateName',
        onCell: () => ({ style: { textAlign: 'center' } }),
        onHeaderCell: () => ({ style: { textAlign: 'center' } }),
      },
      {
        title: '创建时间',
        dataIndex: 'creTime',
        onCell: () => ({ style: { textAlign: 'left' } }),
        onHeaderCell: () => ({ style: { textAlign: 'left' } }),
        render: text => text && moment(text).format('YYYY-MM-DD HH:mm'),
      },
      {
        title: '创建人',
        dataIndex: 'creName',
        onCell: () => ({ style: { textAlign: 'center' } }),
        onHeaderCell: () => ({ style: { textAlign: 'center' } }),
      },
      {
        title: '操作',
        dataIndex: 'operName',
        onCell: () => ({ style: { textAlign: 'center' } }),
        onHeaderCell: () => ({ style: { textAlign: 'center' } }),
        render: (text, record) => (
          <span
            style={{ color: '#1890FF', cursor: 'pointer' }}
            onClick={() => this.jumpRouting('quoId', record.quoId)}
          >
            查看
          </span>
        ),
      },
    ];

    return (
      <div>
        <Card
          style={{ marginBottom: 12 }}
          title={<span style={{ fontWeight: 'bolder' }}>报价单</span>}
          bordered={false}
          id="quotation"
        >
          <Table
            rowSelection={null}
            columns={columns}
            dataSource={crmquoDataList && crmquoDataList.list}
            loading={loading}
            rowKey="quoId"
            pagination={false}
          />
        </Card>
      </div>
    );
  }
}
export default EmpInfor;
